package com.example.demo.service.impl;

import com.example.demo.mapper.CStoreOrderMapper;
import com.example.demo.pojo.CStropShow;
import com.example.demo.service.CStorOrderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CStorOrderImpl implements CStorOrderService {
    @Resource
    CStoreOrderMapper cStoreOrderMapper;

    @Override
    public PageInfo<CStropShow> Cstropshowinfo(Integer page, Integer size, String name, String state,String begin,String end) {
        PageHelper.startPage(page,size);
        List<CStropShow> CStropShows= cStoreOrderMapper.CorderSelect(name,state,begin,end);
        PageInfo<CStropShow> cStropShowPageInfo =new PageInfo<>(CStropShows);
        return cStropShowPageInfo;
    }

    @Override
    public String CorderdelService(String seq) {
        String message="false";
        int a=cStoreOrderMapper.Corderdel(Integer.parseInt(seq));
        if(a>0){
            message="sucess";
        }
        return message;
    }

    @Override
    public String CorderUpdate(String number, String wtid, String salary, String joblocation, String wbegin, String wend, String seq) {
       int worknumber=0;
       int typeid=0;
       int money=0;
        if(number.equals("")){
            worknumber=-1;
       }else{
            worknumber=Integer.parseInt(number);
        }
        if(wtid.equals("")){
            typeid=-1;
        }else{
            typeid=Integer.parseInt(wtid);
        }
        if(salary.equals("")){
            money=-1;
        }else{
            money=Integer.parseInt(salary);
        }

        int a=cStoreOrderMapper.CorderUpdate(worknumber,typeid,money,joblocation,wbegin,wend,1);

        return "sucess";
    }
}
